﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using HousingInfo.Library;

namespace WebHousingInfo
{
    public partial class DienDanBinhLuan : System.Web.UI.Page
    {
        public static string modeid, modedelete, modecate,mode;
        protected void Page_Load(object sender, EventArgs e)
        {
            modedelete = Request.QueryString["deletecomment"];
            modeid = Request.QueryString["id"];
            modecate = Request.QueryString["categoryid"];
            mode = Request.QueryString["idsub"];
            if (modedelete != null)
            {
                ForumCommentBO.DeleteForumCommentBO(Convert.ToInt32(modedelete));
                Response.Redirect("DienDanBinhLuan.aspx?categoryid=" + modecate + "&id=" + modeid);
            }
        }

        protected void btnguitraloinhanh_Click(object sender, EventArgs e)
        {
            ForumCommentBO forumcommentbo = ForumCommentBO.NewForumCommentBO();
            forumcommentbo.ForumNewID = Convert.ToInt32(modeid);
            forumcommentbo.UserName = "admin";
            forumcommentbo.ForumCommentTitle = "";
            forumcommentbo.CommentContent = txttraloinhanh.Text;
            forumcommentbo.CreatedDate = DateTime.Now;
            forumcommentbo.UpdatedDate = DateTime.Now;
            try
            {
                forumcommentbo.Save();
                Response.Redirect("DienDanBinhLuan.aspx?categoryid=" + modecate + "&id=" + modeid);
                btnguitraloinhanh.Focus();
            }
            catch
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('Đã xay ra lỗi khi gửi bài. Xin hãy thử lại !')", true);
                return;
            }
        }

        protected void btntrolai_Click(object sender, EventArgs e)
        {
            Response.Redirect("DienDanTinTheoChuDe.aspx?idsub=" + modecate);
        }

        public static string DeleteQuote(string content)
        {
            try
            {
                content = content.Replace("</blockquote_bydiendanhadat>", "");
                content = content.Replace("<blockquote_bydiendanhadat>", "");
                return content;
            }
            catch
            {
                return content;
            }
        }
    }
}